//
//  WXNetworkService.m
//  6.26项目实战1.1
//
//  Created by lovena on 15/6/26.
//  Copyright (c) 2015年 lovena. All rights reserved.
//

#import "WXNetworkService.h"

@implementation WXNetworkService
+ (id)parserData:(NSString *)name
{
    // 获取到包文件的根目录 沙盒应用程序.app路径
    NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
    
    // 根据传入的名字拼接
    NSString *path = [resourcePath stringByAppendingPathComponent:name];
    
    // 将路径下的数据读出来
    NSData *data = [NSData dataWithContentsOfFile:path];
    
    id result = nil;//返回的数据可能是数组也可能是一个字典
    
    result = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:NULL];
    
    return result;
}// JSON数据解析

+ (id)testData
{
    return [self parserData:@"test.json"];
}
+ (id)northUSAData
{
    //return [[self parserData:@"NorthUSA.json"] objectForKey:@"title"];
    return [[self parserData:@"NorthUSA.json"] objectForKey:@"subjects"];
}

// 分类数据
+ (id)classifyData{
    
    return [[self parserData:@"classify.json"] objectForKey:@"classify"];
}

// 分类商品
+ (id)shopsData{
    
    return [[self parserData:@"shops.json"] objectForKey:@"shops"];
    
}

@end
